package com.sgam.mf.domain.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.springframework.format.annotation.DateTimeFormat;

import com.sgam.mf.domain.ref.RefActivityType;
import com.sgam.mf.domain.ref.RefBank;
import com.sgam.utils.CustomDateDeserializer;
import com.sgam.utils.CustomDateSerializer;

@Entity
@Table(name = "REG_COMPANIES")
public class RegCompanies {


	@Id
	@Column(name = "id")
	@GeneratedValue
	private Integer id;
	
	@Column(name = "idno")
    private String idno;
	 
	@Column(name = "company_name")
    private String companyName;
	
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "foundation_date")
    private Date foundationDate;
	
	
	@Column(name = "boss_name_surname")
    private String bossNameSurname;
	
	
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "boss_birth_date")
    private Date bossBirthDate;
	
	
	@ManyToOne
	@JoinColumn(name = "ref_activity_type_fk", nullable = true)		
    private RefActivityType refActivityType;
	
	@Column(name = "address")
    private String address;
 
	@Column(name = "juridic_address")
    private String juridicAddress;	

	@Column(name = "emal")
    private String emal;	
	
	@Column(name = "phone_mob")
    private String phoneMob;
	
	@Column(name = "phone_serv")
    private String phoneServ;
	
	@Column(name = "skype")
    private String skype;
	
	@Column(name = "company_site")
    private String companySite;
	
	@ManyToOne
	@JoinColumn(name = "ref_bank_fk", nullable = true)	
    private RefBank refBank;
	
	@Column(name = "bank_code")
    private String bankCode;
	
	@Column(name = "bank_account")
    private String bankAccount;	
	
	@Column(name = "notes")
    private String notes;
	
	@Column(name = "updated_by_fk")
    private Integer updatedByFk;	
	
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "updated_date")
    private Date updatedDate;
	
//	@JsonSerialize(using = CustomDateSerializer.class)
//	@JsonDeserialize(using = CustomDateDeserializer.class)
//	@DateTimeFormat(pattern="dd.MM.yyyy")
//	@Column(name = "asig_rca_date")
//    private Date asigRcaDate;	
//	
//	@JsonSerialize(using = CustomDateSerializer.class)
//	@JsonDeserialize(using = CustomDateDeserializer.class)
//	@DateTimeFormat(pattern="dd.MM.yyyy")
//	@Column(name = "asig_casco_date")
//    private Date asigCascoDate;	
	
	@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval=true)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(name="parent_id_fk")
//	@OrderBy("refPropertyType.id")
	private List<RegCompaniesAss> regCompaniesAss =  new ArrayList<RegCompaniesAss>();
	
	@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval=true)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(name="reg_companies_id_fk")
	@OrderBy("refDomains.id")
	private List<ClientFiles> clientFiles = new ArrayList<ClientFiles>();
	
	@Column(name = "tva")
    private String tva;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getIdno() {
		return idno;
	}

	public void setIdno(String idno) {
		this.idno = idno;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public Date getFoundationDate() {
		return foundationDate;
	}

	public void setFoundationDate(Date foundationDate) {
		this.foundationDate = foundationDate;
	}

	public String getBossNameSurname() {
		return bossNameSurname;
	}

	public void setBossNameSurname(String bossNameSurname) {
		this.bossNameSurname = bossNameSurname;
	}
	

	public Date getBossBirthDate() {
		return bossBirthDate;
	}

	public void setBossBirthDate(Date bossBirthDate) {
		this.bossBirthDate = bossBirthDate;
	}

	public RefActivityType getRefActivityType() {
		return refActivityType;
	}

	public void setRefActivityType(RefActivityType refActivityType) {
		this.refActivityType = refActivityType;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getJuridicAddress() {
		return juridicAddress;
	}

	public void setJuridicAddress(String juridicAddress) {
		this.juridicAddress = juridicAddress;
	}

	public String getEmal() {
		return emal;
	}

	public void setEmal(String emal) {
		this.emal = emal;
	}

	public String getPhoneMob() {
		return phoneMob;
	}

	public void setPhoneMob(String phoneMob) {
		this.phoneMob = phoneMob;
	}

	public String getPhoneServ() {
		return phoneServ;
	}

	public void setPhoneServ(String phoneServ) {
		this.phoneServ = phoneServ;
	}

	public String getSkype() {
		return skype;
	}

	public void setSkype(String skype) {
		this.skype = skype;
	}

	public String getCompanySite() {
		return companySite;
	}

	public void setCompanySite(String companySite) {
		this.companySite = companySite;
	}

	public RefBank getRefBank() {
		return refBank;
	}

	public void setRefBank(RefBank refBank) {
		this.refBank = refBank;
	}

	public String getBankCode() {
		return bankCode;
	}

	public void setBankCode(String bankCode) {
		this.bankCode = bankCode;
	}

	public String getBankAccount() {
		return bankAccount;
	}

	public void setBankAccount(String bankAccount) {
		this.bankAccount = bankAccount;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Integer getUpdatedByFk() {
		return updatedByFk;
	}

	public void setUpdatedByFk(Integer updatedByFk) {
		this.updatedByFk = updatedByFk;
	}

	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public List<RegCompaniesAss> getRegCompaniesAss() {
		return regCompaniesAss;
	}

	public void setRegCompaniesAss(List<RegCompaniesAss> regCompaniesAss) {
		this.regCompaniesAss = regCompaniesAss;
	}

	public List<ClientFiles> getClientFiles() {
		return clientFiles;
	}

	public void setClientFiles(List<ClientFiles> clientFiles) {
		this.clientFiles = clientFiles;
	}

	public String getTva() {
		return tva;
	}

	public void setTva(String tva) {
		this.tva = tva;
	}
	
	
	

//	public Date getAsigRcaDate() {
//		return asigRcaDate;
//	}
//
//	public void setAsigRcaDate(Date asigRcaDate) {
//		this.asigRcaDate = asigRcaDate;
//	}
//
//	public Date getAsigCascoDate() {
//		return asigCascoDate;
//	}
//
//	public void setAsigCascoDate(Date asigCascoDate) {
//		this.asigCascoDate = asigCascoDate;
//	}
	
	

	
}


 

